package com.techwells.learningkites.adapter;

import java.io.Serializable;
import java.util.List;

import com.techwells.learningkites.R;
import com.techwells.learningkites.networkservice.model.CourseCategory;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

public class MyListAdapter extends BaseAdapter {
	
	private Context mContext;
	private LayoutInflater mInflater;
	private List<String> mList;

	
	public MyListAdapter(Context mContext, List<String> mList) {
		super();
		this.mContext = mContext;
		mInflater =(LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
		this.mList = mList;
	}

	@Override
	public int getCount() {
		// TODO Auto-generated method stub
		return mList.size();
	}

	@Override
	public Object getItem(int arg0) {
		// TODO Auto-generated method stub
		return mList.get(arg0);
	}

	@Override
	public long getItemId(int position) {
		// TODO Auto-generated method stub
		return position;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		CellHolder cellHolder;
        if (convertView == null) {
        	cellHolder = new CellHolder();
        		convertView = mInflater.inflate(R.layout.item_mylist, null);
        		cellHolder.myItem = (TextView) convertView.findViewById(R.id.tv_title);
                convertView.setTag(cellHolder);

        } else {
        	cellHolder = (CellHolder) convertView.getTag();
        }        
        
        cellHolder.myItem.setText(mList.get(position).toString());
       
		return convertView;
	}

	
	public static class CellHolder implements Serializable{
    	TextView myItem;
    }
}
